package com.ruoyi.project.jiaqin.twoclasstrend.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.twoclasstrend.domain.TwoClassTrend;
import com.ruoyi.project.jiaqin.twoclasstrend.service.ITwoClassTrendService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 二级分类价格走势Controller
 * 
 * @author admin
 * @date 2021-01-09
 */
@Controller
@RequestMapping("/jiaqin/twoclasstrend")
public class TwoClassTrendController extends BaseController
{
    private String prefix = "jiaqin/twoclasstrend";

    @Autowired
    private ITwoClassTrendService twoClassTrendService;

    @RequiresPermissions("jiaqin:twoclasstrend:view")
    @GetMapping()
    public String twoclasstrend()
    {
        return prefix + "/twoclasstrend";
    }

    /**
     * 查询二级分类价格走势列表
     */
    @RequiresPermissions("jiaqin:twoclasstrend:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TwoClassTrend twoClassTrend)
    {
        startPage();
        List<TwoClassTrend> list = twoClassTrendService.selectTwoClassTrendList(twoClassTrend);
        return getDataTable(list);
    }

    /**
     * 导出二级分类价格走势列表
     */
    @RequiresPermissions("jiaqin:twoclasstrend:export")
    @Log(title = "二级分类价格走势", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TwoClassTrend twoClassTrend)
    {
        List<TwoClassTrend> list = twoClassTrendService.selectTwoClassTrendList(twoClassTrend);
        ExcelUtil<TwoClassTrend> util = new ExcelUtil<TwoClassTrend>(TwoClassTrend.class);
        return util.exportExcel(list, "twoclasstrend");
    }

    /**
     * 新增二级分类价格走势
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存二级分类价格走势
     */
    @RequiresPermissions("jiaqin:twoclasstrend:add")
    @Log(title = "二级分类价格走势", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TwoClassTrend twoClassTrend)
    {
        return toAjax(twoClassTrendService.insertTwoClassTrend(twoClassTrend));
    }

    /**
     * 修改二级分类价格走势
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        TwoClassTrend twoClassTrend = twoClassTrendService.selectTwoClassTrendById(id);
        mmap.put("twoClassTrend", twoClassTrend);
        return prefix + "/edit";
    }

    /**
     * 修改保存二级分类价格走势
     */
    @RequiresPermissions("jiaqin:twoclasstrend:edit")
    @Log(title = "二级分类价格走势", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TwoClassTrend twoClassTrend)
    {
        return toAjax(twoClassTrendService.updateTwoClassTrend(twoClassTrend));
    }

    /**
     * 删除二级分类价格走势
     */
    @RequiresPermissions("jiaqin:twoclasstrend:remove")
    @Log(title = "二级分类价格走势", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(twoClassTrendService.deleteTwoClassTrendByIds(ids));
    }
}
